package org.springblade.modules.item.task;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.item.service.RfidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;


/**
 * RFID每隔1分钟刷新一次数据
 */
@Service
@Slf4j
public class RfidSchedulingTask {

	@Autowired
	private  RfidService rfidService;

	@Value("${env}")
	private String env;


	@Scheduled(cron = "0/10 * * * * ? ")
	public void task(){
		if (StringUtils.isNotBlank(env) && "prod".equals(env)  ){
			long startTime=System.currentTimeMillis();
			log.info("rfid任务调度开始....");
			rfidService.tcpReadTagTask();
			log.info("rfid任务调度结束,耗时{}毫秒",System.currentTimeMillis()-startTime);
		}
	}
}
